package com.xiaoke.controller;

import com.xiaoke.domain.R;
import com.xiaoke.domain.dtos.LoginDto;
import com.xiaoke.domain.vos.LoginCodeVo;
import com.xiaoke.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author xiaoke
 * @Description 登录控制器
 * @Date 2023/7/24 13:12
 */
@RestController
@RequestMapping("/auth")
public class LoginController {

    @Autowired
    LoginService loginService;

    /**
     * 登录
     * @param dto 请求参数
     */
    @PostMapping("/login")
    public R<String> login(@RequestBody @Validated LoginDto dto) {
        return loginService.login(dto);
    }


    /**
     *
     * @return 验证码vo
     */
    @GetMapping("/code")
    public R<LoginCodeVo> code(){
        return loginService.code();
    }


}
